<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        vue模板
        <!-- dblclick 双击 
         click 点击 
         mouseenter 鼠标移入 
         mouseout 鼠标移出
        
-->
        <button v-on:click="desc">-</button>
        <span>{{totalCount}}</span>
        <button v -on:click="desc2">+</button>
    </div>
    <script src="./vue.js"></script>
    <script>
        const app = new Vue({
            el: "#app",
            data: {
                totalCount: 1
            },
            methods: {
                desc() {
                    if (app.totalCount === 1) {
                        alert('不能再减了')
                        return
                    } else {
                        app.totalCount--
                    }
                },
                desc2() {
                    if (app.totalCount === 10) {
                        alert('不能再加了')
                        return
                    } else {  
                        app.totalCount++
                    }
                }
            }
        })
    </script>

</html>